home *** CD-ROM | disk | FTP | other *** search
/ El Mac 9 / El Mac 9.iso / Shareware / Applications / MathPad 2.4 / XFuns / XFun kit / util src / A4globs.h next >
Encoding:
C/C++ Source or Header  |  1995-12-22  |  984 b   |  42 lines  |  [TEXT/CWIE]

  1. /*
  2.    Yet another header with macros for setting up A4 globals in 68K code resources.
  3.    This handles either Think C or CodeWarrior with minimal fuss.
  4.    
  5.    The main() entry calls EnterResource() ... RestoreA4().
  6.    All other entries call SetUpA4() ... RestoreA4().
  7.    
  8.    CodeWarrior provides 2 headers: <A4Stuff.h> and <SetUpA4.h> which define several
  9.    macros. None of these work as simply as the Think C <SetUpA4.h>.
  10. */
  11.  
  12. #ifdef THINK_C
  13.  #include <SetUpA4.h>
  14.  #define EnterResource() RememberA0(); SetUpA4()
  15. #else
  16.  #define EnterResource() long oldA4 = SetCurrentA4(); SaveA4()
  17.  #define SetUpA4() long oldA4 = RecallA4()
  18.  #define RestoreA4() SetA4(oldA4)
  19.  
  20. /* stolen from CodeWarrior <SetUpA4.h> */
  21.  long SetCurrentA4(void);
  22.  
  23.  long SetA4(long:__D0):__D0 = 0xC18C;
  24.  
  25.  static void SaveA4(void);
  26.  
  27.  static asm long RecallA4(void)    
  28.     {
  29.         move.l    a4,d0
  30.         lea        storage,a4
  31.         move.l    (a4),a4
  32.         rts
  33.     
  34.     storage:    dc.l    0
  35.     
  36.         entry    static SaveA4
  37.         lea        storage,a0
  38.         move.l    a4,(a0)
  39.         rts
  40.     }
  41. #endif
  42.